import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:ichinesereader/constants.dart';
import 'package:ichinesereader/pages/common/myWords.dart';
import 'package:ichinesereader/pages/student/myFavoriteBooks.dart';
import 'package:ichinesereader/routes/routePages.dart';
import 'package:ichinesereader/utils/log.dart';
import 'package:ichinesereader/widgets/layouts/appdrawerStudent.dart';
import 'package:ichinesereader/widgets/layouts/customAppBar.dart';
import 'package:ichinesereader/widgets/sidebars/studentSidebar.dart';
import '../../themes/appTheme.dart';
import '../../themes/pageStyles.dart';

class MyFavoritesPageForStudent extends StatelessWidget {
  static const String routeName = '/student/myfavorites';

  @override
  Widget build(BuildContext context) {
    Log.debug('build student myfavorites');
    final isSmallScreen =
        MediaQuery.of(context).size.width < Constants.DefinedScreenSmallSize;
    final isBigScreen =
        MediaQuery.of(context).size.width > Constants.DefinedScreenBigSize;
    int _selectedSidebarItem = RoutePages.studentPageItems
        .indexWhere((page) => page.route == Get.currentRoute);
    final PageStyles _pageStyles = PageStyles();

    return DefaultTabController(
        length: 2,
        child: Scaffold(
          appBar: isSmallScreen ? CustomAppBar(title: 'My Favorites'.tr) : null,
          drawer: isSmallScreen ? StudentAppDrawer() : null,
          body: Container(
            decoration: _pageStyles.pageBoxDecoration(),
            child: Row(
              children: [
                Visibility(
                    visible: !isSmallScreen,
                    child: StudentSidebarX(
                        selectedIndex: _selectedSidebarItem,
                        isBigScreen: isBigScreen)),
                Expanded(
                  child: Container(
                    margin: _pageStyles.mainContainerPageEdgeInsets(),
                    child: Column(
                      children: [
                        Stack(
                          alignment: Alignment.center,
                          children: [
                            Container(
                              margin: EdgeInsets.only(bottom: 12.0),
                              padding: EdgeInsets.symmetric(vertical: 12.0),
                              decoration: BoxDecoration(
                                color: Get.isDarkMode
                                    ? AppTheme.colors.darkTheme2
                                    : Colors.black.withOpacity(0.1),
                                borderRadius: BorderRadius.circular(3.0),
                              ),
                              child: _pageStyles.buildTabBar([
                                'My Books',
                                'My Words',
                              ]),
                            ),
                          ],
                        ),
                        Expanded(
                          flex: 9,
                          child: Container(
                            child: TabBarView(
                              children: [
                                MyFavoriteBooksForStudent(),
                                MyKnowledgeWordsPage(
                                  folderId: '',
                                  level: '',
                                  isMainFolder: true,
                                )
                              ],
                            ),
                          ),
                        )
                      ],
                    ),
                  ),
                ),
              ],
            ),
          ),
        ));
  }
}
